package Strategy;

import java.util.Arrays;
import java.util.List;

// 农田地图类
public class FieldMap {
    List<Coordinate> obstaclePositions; // 障碍物坐标列表
    Coordinate fieldBoundaryMin; // 农田边界（最小坐标）
    Coordinate fieldBoundaryMax; // 农田边界（最大坐标）

    public FieldMap() {
        // 使用 Arrays.asList 替代 List.of
        this.obstaclePositions = Arrays.asList(
                new Coordinate(5, 5),
                new Coordinate(10, 8)
        );
        this.fieldBoundaryMin = new Coordinate(0, 0);
        this.fieldBoundaryMax = new Coordinate(20, 20);
    }

    // 获取障碍物位置列表
    public List<Coordinate> getObstaclePositions() {
        return obstaclePositions;
    }

    // 判断坐标是否在农田边界内
    public boolean isWithinBoundary(Coordinate position) {
        return position.getX() >= fieldBoundaryMin.getX() &&
                position.getX() <= fieldBoundaryMax.getX() &&
                position.getY() >= fieldBoundaryMin.getY() &&
                position.getY() <= fieldBoundaryMax.getY();
    }

    // 获取农田宽度
    public double getWidth() {
        return fieldBoundaryMax.getX() - fieldBoundaryMin.getX();
    }

    // 获取农田高度
    public double getHeight() {
        return fieldBoundaryMax.getY() - fieldBoundaryMin.getY();
    }

    public void setObstaclePositions(List<Coordinate> obstaclePositions) {
        this.obstaclePositions = obstaclePositions;
    }

    public Coordinate getFieldBoundaryMin() {
        return fieldBoundaryMin;
    }

    public void setFieldBoundaryMin(Coordinate fieldBoundaryMin) {
        this.fieldBoundaryMin = fieldBoundaryMin;
    }

    public Coordinate getFieldBoundaryMax() {
        return fieldBoundaryMax;
    }

    public void setFieldBoundaryMax(Coordinate fieldBoundaryMax) {
        this.fieldBoundaryMax = fieldBoundaryMax;
    }
}

